package com.example.administrator.zhongyichou.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseExpandableListAdapter;
import android.widget.TextView;

import com.example.administrator.zhongyichou.R;

/**
 * Created by lichenyu on 2017/11/22.
 * 描述：
 */

public class MillionsHelpExpandableAdapter extends BaseExpandableListAdapter {

    private Context context;

    public MillionsHelpExpandableAdapter(Context context) {
        this.context = context;
    }

    private String[] parentContent = {"Q1 什么是百万终身大病互助行动？", "Q2 什么人可以加入百万终身大病互助行动？", " Q3什么情况可以获得互助金？"};
    private String[] childContent = {"轻松互助为指定重疾持续、扩散、复发或新确诊提供最多2次互助，每次互助金额最高为50万，共计最高103万。",
            "出生28天-50周岁的轻松互助会员且身体健康时可以加入本互助行动。只要一直不退出该行动，会员可延续至终身。",
            "当互助会员已获得最高30万元互助金（除低度恶性肿瘤外所有30种重大疾病），若会员其后确诊重大疾病，只须于确诊日起计生存超过15日及合符相关等待期要求，即可申请互助。"};

    //要做判空处理
    @Override
    public int getGroupCount() {
        return 3;
    }

    @Override
    public int getChildrenCount(int groupPosition) {
        return 1;
    }

    @Override
    public Object getGroup(int groupPosition) {
        return null;
    }

    @Override
    public Object getChild(int groupPosition, int childPosition) {
        return null;
    }

    @Override
    public long getGroupId(int groupPosition) {
        return 0;
    }

    @Override
    public long getChildId(int groupPosition, int childPosition) {
        return 0;
    }

    @Override
    public boolean hasStableIds() {
        return false;
    }

    @Override
    public View getGroupView(int groupPosition, boolean isExpanded, View convertView, ViewGroup parent) {
        if (convertView == null) {
            convertView = LayoutInflater.from(context).inflate(R.layout.millions_help_list_item, null);
        }
        TextView textView = (TextView) convertView.findViewById(R.id.txt_name);
        textView.setText(parentContent[groupPosition]);
        return convertView;
    }

    @Override
    public View getChildView(int groupPosition, int childPosition, boolean isLastChild, View convertView, ViewGroup parent) {
        if (convertView == null) {
            convertView = LayoutInflater.from(context).inflate(R.layout.millions_help_list_item1, null);
        }
        TextView textView = (TextView) convertView.findViewById(R.id.txt_content);
        textView.setText(childContent[groupPosition]);
        return convertView;
    }

    @Override
    public boolean isChildSelectable(int groupPosition, int childPosition) {
        return false;
    }
}
